package com.cskaoyan.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * 视图相关的返回值
 * 响应视图的话，不要增加@ResponseBody
 */
@Controller
public class ViewController {

    @RequestMapping("view1")
    public ModelAndView view1() {
        ModelAndView modelAndView = new ModelAndView("/view.jsp");
        modelAndView.addObject("view", "view1");
        return modelAndView;
    }

    @RequestMapping("view2")
    public String view2(Model model) {
        model.addAttribute("view", "view2");
        return "/view.jsp";//ModelAndView中的viewName
    }
}
